<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>手机号：</p>
                            <input type="text" name="phone"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:tuser:add">-->
            <!--                    <i class="fa fa-plus"></i> 添加-->
            <!--                </a>-->
            <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:tuser:edit">-->
            <!--                    <i class="fa fa-edit"></i> 修改-->
            <!--                </a>-->
            <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:tuser:remove">-->
            <!--                    <i class="fa fa-remove"></i> 删除-->
            <!--                </a>-->
            <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:tuser:export">-->
            <!--                    <i class="fa fa-download"></i> 导出-->
            <!--                 </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:tuser:edit')}]];

    var editName = [[${@permission.hasPermi('system:tuser:editname')}]];
    var editcar = [[${@permission.hasPermi('system:tuser:editcar')}]];
    var edithouse = [[${@permission.hasPermi('system:tuser:edithouse')}]];

    var prefix = ctx + "system/tuser";


    function editNameFun(id) {
        var url = prefix + "/editname/" + id;
        layer.open({
            type: 2,
            area: ['800px', '500px'],
            maxmin: true,
            title: "实名认证审核",
            content: url,
            btn: ['关闭']
        });
    }


    function editHouseFun(id) {
        var url = prefix + "/edithouse/" + id;
        layer.open({
            type: 2,
            area: ['800px', '500px'],
            maxmin: true,
            title: "房屋认证审核",
            content: url,
            btn: ['关闭']
        });
    }


    function editCarFun(id) {
        var url = prefix + "/editcar/" + id;
        layer.open({
            type: 2,
            area: ['800px', '500px'],
            maxmin: true,
            title: "车辆认证审核",
            content: url,
            btn: ['关闭']
        });
    }


    $(function () {

        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/edit/{id}",
            editNameUrl: prefix + "/editname/{id}",
            editHouseUrl: prefix + "/edithouse/{id}",
            editCarUrl: prefix + "/editcar/{id}",

            modalName: "用户",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '标识',
                    visible: false
                },
                {
                    field: 'phone',
                    title: '账号'
                },
                {
                    field: 'headPortrait',
                    title: '头像',
                    formatter: function (value, row, index) {
                        if (value == null || value == "") {
                            return "未设置";
                        }

                        return $.table.imageView(value, 200, 200)

                    }
                },
                {
                    field: 'nickName',
                    title: '昵称'
                },
                {
                    field: 'phoneNumber',
                    title: '手机号'
                },
                {
                    field: 'weChat',
                    title: '微信号'
                },
                {
                    field: 'sex',
                    title: '性别'
                },
                {
                    field: 'realNameState',
                    title: '实名认证',
                    formatter: function (value, row, index) {
                        if (value == null || value == "") {
                            return "未认证";
                        } else if (value == 0) {
                            return "未认证";
                        } else if (value == 1) {
                            return "审核中";
                        } else if (value == 2) {
                            return "审核失败";
                        } else if (value == 3) {
                            return "认证成功";
                        }
                    }
                },
                {
                    field: 'realCarState',
                    title: '车辆认证',
                    formatter: function (value, row, index) {
                        if (value == null || value == "") {
                            return "未认证";
                        } else if (value == 0) {
                            return "未认证";
                        } else if (value == 1) {
                            return "审核中";
                        } else if (value == 2) {
                            return "审核失败";
                        } else if (value == 3) {
                            return "认证成功";
                        }
                    }
                },
                {
                    field: 'realHouseState',
                    title: '房屋认证',
                    formatter: function (value, row, index) {
                        if (value == null || value == "") {
                            return "未认证";
                        } else if (value == 0) {
                            return "未认证";
                        } else if (value == 1) {
                            return "审核中";
                        } else if (value == 2) {
                            return "审核失败";
                        } else if (value == 3) {
                            return "认证成功";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="glyphicon glyphicon-search"></i>详情</a> ');
                        actions.push('<a class="fa fa-edit ' + editName + '" href="javascript:void(0)" onclick="editNameFun(\'' + row.id + '\')">实名</a>');
                        actions.push('<a class="fa fa-edit ' + edithouse + '" href="javascript:void(0)" onclick="editHouseFun(\'' + row.id + '\')">房屋</a>');
                        actions.push('<a class="fa fa-edit ' + editcar + '" href="javascript:void(0)" onclick="editCarFun(\'' + row.id + '\')">车辆</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

    });


</script>
</body>
</html>